<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">材料名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="listname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">是否有库存：</label>
                        <div class="layui-input-block">
                            <select id="isku" name="isku" lay-filter="isku">
                                <option value="0">全部</option>
                                <option value="1" selected>有库存</option>
                                <option value="2">无库存</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <input type="hidden" id="enginid" name="enginid">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <?php include '../public/engin_dao.php' ?>
            <div class="layui-col-md10" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>




    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('材料库存统计');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_stuff_ku_list),where: {isku:1}, page: false, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);



                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'enginid_name', title: '项目名称',event: 'enginid_name',templet: function(d){
                        return '<span class="colorlan">'+d.enginid_name+'</span>';
                    }}
                ,{field: 'name', title: '材料名称',merge:true}
                ,{field: 'unit', title: '单位'}
                ,{field: 'listnum', title: '入库数量',totalRow: true,align:'right',event: 'detail1',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.listnum)+'</span>';
                    }}
                ,{field: 'listmoney', title: '入库金额(元)',totalRow: true,align:'right'}
                ,{field: 'chu_num', title: '出库数量',totalRow: true,align:'right',event: 'detail2',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.chu_num)+'</span>';
                    }}
                ,{field: 'chu_money', title: '出库金额(元)',totalRow: true,align:'right'}
                ,{field: 'tui_num', title: '退库数量',totalRow: true,align:'right',event: 'detail3',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.tui_num)+'</span>';
                    }}
                ,{field: 'tui_money', title: '退库金额(元)',totalRow: true,align:'right'}
                ,{field: 'hao_num', title: '耗用数量',totalRow: true,align:'right'}
                ,{field: 'hao_money', title: '耗用金额(元)',totalRow: true,align:'right'}
                ,{field: 'ku_num', title: '库存数量',totalRow: true,align:'right'}
                ,{field: 'ku_money', title: '库存金额(元)',totalRow: true,align:'right'}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });


        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'enginid_name'){
                openPage('../engin/show.php?id='+data.enginid);
            }
            if(obj.event === 'detail1'){
                openPage('./detail.php?chatype=1&idstr='+data.idstr, '80%', '80%');
            }
            if(obj.event === 'detail2'){
                openPage('./detail.php?chatype=2&idstr='+data.idstr, '80%', '80%');
            }
            if(obj.event === 'detail3'){
                openPage('./detail.php?chatype=3&idstr='+data.idstr, '80%', '80%');
            }
        });

        listTableSearch(form, table);
    });




</script>
</body>
</html>
